<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title></title>
    <link  href="loanStatic/css/common.css"
    	th:href="@{/loanStatic/css/common.css?v=3.3.6}" rel="stylesheet">
    <link  href="loanStatic/css/login.css"
    	th:href="@{/loanStatic/css/login.css?v=3.3.6}" rel="stylesheet">
    <link th:href="@{/loanStatic/tip/mdialog.css}" rel="stylesheet" type="text/css">
    <script th:src="@{/loanStatic/tip/mdialog.js}"></script>
     <script th:src="@{/loanStatic/js/fromSumbit/jquery.min.js}" type="text/javascript"></script>
</head>
<body>
    <div id="login"></div>
    <div class="login_bg">
        <div id="logo">
            <img style="width:109px;height:109px" th:src="@{/loanStatic/images/logo.png}" alt=""/>
        </div>
        <div style="width: 80%; margin: 0 auto;text-align: left">
            <div class="userName">
                <lable>手机号：</lable>
                <input type="text" name="mobile" id="mobile" placeholder="请输入手机号" />
            </div><br/>
            <div class="passWord">
                <lable>密&nbsp;&nbsp;&nbsp;码：</lable>
                <input type="password" name="password" id="password" placeholder="请输入密码"/>
            </div>
            <div class="choose_box">
                <div>
                    <input type="checkbox" checked="checked" name="checkbox"/>
                    <lable>记住密码</lable>
                </div>
                <a th:href="@{/moblie/forgetPassword}">忘记密码</a>
            </div>
            <button class="login_btn" onclick="loginBtn();" type="submit">登&nbsp;&nbsp;录</button>
        </div>
        <div class="other_login">
            <div class="other"></div>
            <span onclick="continueRegister();">切换继续注册</span>
            <div class="other"></div>
        </div>
        <div class="other_choose">
            <a>
                <img th:src="@{/loanStatic/images/qq.png}" alt=""/>
            </a>
            <a>
                <img th:src="@{/loanStatic/images/wx.png}" alt=""/>
            </a>
            <a>
                <img th:src="@{/loanStatic/images/wb.png}" alt=""/>
            </a>
        </div>
    </div>
   <script>
   function continueRegister(){
	   window.location.href="/moblie/register";
   }
   
   function loginBtn(){
	var mobile = $("#mobile").val();
   	var password = $("#password").val();
   	var regex = /^(((1[3456789][0-9]{1})|(15[0-9]{1}))+\d{8})$/;
   		if("" == mobile|| mobile==null){
			new TipBox({type:'tip',str:'手机号码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
   			return;
		}
		if (!regex.test(mobile)) {
			new TipBox({type:'tip',str:'手机格式不正确',clickDomCancel:true,setTime:1000,hasBtn:false}); 
   			return;
		}
		if("" == password|| password==null){
			new TipBox({type:'tip',str:'密码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
   			return;
		}
		
		$.ajax({
			url : "/moblie/loginBtn",
			data : {"mobile": mobile,"password":password},
			dataType : "json",
			type : 'post',
			success : function(data) {
				if (data=='200') {
					new TipBox({type:'success',str:'登录成功！',clickDomCancel:true,setTime:1000,hasBtn:false});
					setTimeout("window.location.href='/moblie/home'",1300)
				}else if(data=='202'){
					new TipBox({type:'error',str:'发送失败！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='203'){
					new TipBox({type:'tip',str:'手机号不存在！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='204'){
					new TipBox({type:'tip',str:'密码不正确！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='205'){
					new TipBox({type:'tip',str:'账号已锁定！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}
				
			},
			error : function() {
				alert("网络异常，请稍后重试！");
			}
		});
		
		
   }
   </script>
</body>
</html>